package xiang.clients.fallBack;

import com.xiang.utils.AjaxResult;
import feign.hystrix.FallbackFactory;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.annotation.Configuration;
import xiang.clients.InfoClient;

/**
 * @author xiangtianlei
 * @date 2024/04/16
 */
@Configuration
public class InfoClientFallBackFactory implements FallbackFactory<InfoClient> {
    private final Logger logger = LoggerFactory.getLogger(InfoClientFallBackFactory.class);

    @Override
    public InfoClient create(Throwable throwable) {
        return new InfoClient() {
            @Override
            public AjaxResult getInfo() {
                logger.error("报错：{}", throwable);
                return AjaxResult.error("查询报错");
            }
        };
    }
}
